package com.example.blog_spring.mapper;

import com.example.blog_spring.model.UserInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {
    /**
     * 根据用户名查用户信息
     * @return
     */
    @Select("select * from user where user_name = #{name} and delete_flag != 1")
    UserInfo selectByName(String name);

    /**
     * 根据Id查用户信息
     * @return
     */
    @Select("select * from user where id = #{id} and delete_flag != 1")
    UserInfo selectById(Integer id);

    @Insert("insert into user (user_name, password, github_url) values (#{userName}, #{password}, #{github})")
    Integer addUserInfo(@Param("userName") String userName,
                        @Param("password") String password,
                        @Param("github") String github);

    Integer updateUserInfo(UserInfo userInfo);
}
